home *** CD-ROM | disk | FTP | other *** search
/ PC Plus SuperCD (UK) 1997 May / PC Plus Super CD Issue 127 (May 1997).iso / fixes / java125 / applet1.class (.txt) next >
Encoding:
Java Class File  |  1996-12-03  |  2.2 KB  |  63 lines

  1. import java.applet.Applet;
  2. import java.awt.Color;
  3. import java.awt.Container;
  4. import java.awt.Event;
  5. import java.awt.Font;
  6. import java.awt.Label;
  7. import java.awt.LayoutManager;
  8. import java.awt.Panel;
  9. import java.awt.Scrollbar;
  10.  
  11. public class Applet1 extends Applet {
  12.    Scrollbar verticalScrollbar1;
  13.    Label label1;
  14.    Label label2;
  15.    Label label3;
  16.    Label label4;
  17.    Label label5;
  18.    Label label6;
  19.  
  20.    public void init() {
  21.       super.init();
  22.       ((Container)this).setLayout((LayoutManager)null);
  23.       ((Panel)this).addNotify();
  24.       ((Applet)this).resize(311, 211);
  25.       this.verticalScrollbar1 = new Scrollbar(1, 0, 0, 0, 200);
  26.       this.verticalScrollbar1.reshape(140, 60, 16, 120);
  27.       ((Container)this).add(this.verticalScrollbar1);
  28.       this.label1 = new Label("0");
  29.       this.label1.reshape(42, 75, 70, 15);
  30.       this.label1.setFont(new Font("Dialog", 1, 12));
  31.       ((Container)this).add(this.label1);
  32.       this.label2 = new Label("0");
  33.       this.label2.reshape(203, 75, 70, 15);
  34.       this.label2.setFont(new Font("Dialog", 1, 12));
  35.       ((Container)this).add(this.label2);
  36.       this.label3 = new Label("Centigrade");
  37.       this.label3.reshape(42, 53, 84, 15);
  38.       ((Container)this).add(this.label3);
  39.       this.label4 = new Label("Fahrenheit");
  40.       this.label4.reshape(203, 53, 70, 15);
  41.       this.label4.setFont(new Font("Dialog", 0, 12));
  42.       ((Container)this).add(this.label4);
  43.       this.label5 = new Label("0 -");
  44.       this.label5.reshape(105, 68, 28, 15);
  45.       this.label5.setFont(new Font("Dialog", 2, 12));
  46.       ((Container)this).add(this.label5);
  47.       this.label6 = new Label("200 -");
  48.       this.label6.reshape(98, 158, 42, 15);
  49.       this.label6.setFont(new Font("Dialog", 2, 12));
  50.       this.label6.setForeground(new Color(0));
  51.       ((Container)this).add(this.label6);
  52.    }
  53.  
  54.    public boolean handleEvent(Event event) {
  55.       if (event.target == this.verticalScrollbar1) {
  56.          this.label1.setText("" + this.verticalScrollbar1.getValue());
  57.          this.label2.setText("" + (this.verticalScrollbar1.getValue() * 9 / 5 + 32));
  58.       }
  59.  
  60.       return super.handleEvent(event);
  61.    }
  62. }
  63.